Enable detectAsyncLeaks in Vitest tests#7616
Conversation
|
Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
|
|
@copilot Can you see the CI / type-check error and fix it? |
Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Fixed in b9ab414. The |
|
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
|
@copilot resolve the merge conflicts in this pull request |
…-async-leaks # Conflicts: # package-lock.json # package.json Co-authored-by: siddharthkp <1863771+siddharthkp@users.noreply.github.com>
Resolved in 572f65c. The conflicts were in |
There was a problem hiding this comment.
Pull request overview
Enables Vitest’s detectAsyncLeaks: true across all Node-environment Vitest configurations in the monorepo to help catch asynchronous resource leaks (e.g., uncleared timers / pending async work) during Node-based test runs.
Changes:
- Added
detectAsyncLeaks: trueto the Node test config in@primer/react. - Added
detectAsyncLeaks: trueto the Node test config in@primer/styled-react. - Added
detectAsyncLeaks: trueto the Node test config in@primer/doc-genand@primer/postcss-preset-primer.
Show a summary per file
| File | Description |
|---|---|
| packages/react/vitest.config.mts | Enables async leak detection for the node-environment test suite. |
| packages/styled-react/vitest.config.ts | Enables async leak detection for the node-environment test suite. |
| packages/doc-gen/vitest.config.mts | Enables async leak detection for node-environment tests. |
| packages/postcss-preset-primer/vitest.config.ts | Enables async leak detection for node-environment tests. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 0
Enables
detectAsyncLeaks: truein all node-environment Vitest configurations to detect asynchronous resource leaks (e.g., uncleared timers, pending promises) in node-based test runs. Also upgrades vitest to4.1.5(stable release), which includes TypeScript type support for thedetectAsyncLeaksoption.Changelog
New
detectAsyncLeaks: trueadded to all node-environment vitest configs:packages/react/vitest.config.mtspackages/doc-gen/vitest.config.mtspackages/styled-react/vitest.config.tspackages/postcss-preset-primer/vitest.config.tsChanged
vitest,@vitest/browser, and@vitest/browser-playwrightfrom^4.0.15to^4.1.5to support thedetectAsyncLeaksTypeScript type inInlineConfigRemoved
Rollout strategy
Config-only change with a vitest dev-dependency bump. No public API impact.
Testing & Reviewing
Browser-based vitest configs (
vitest.config.browser.mts,vitest.config.browser.ts) are intentionally excluded —detectAsyncLeaksuses Node.jsasync_hooksand is not applicable to Chromium/Playwright environments.Merge checklist
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.